package com.alks.function.service.impl.system;

import com.alks.common.aop.AutoPageAop;
import com.alks.common.data.thread.UserIdThread;
import com.alks.common.service.ILogService;
import com.alks.entity.data.entity.sys.SysLog;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.mapper.system.SysLogMapper;
import com.alks.function.service.system.SysLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;


@Service
@Slf4j
@RequiredArgsConstructor
@Primary
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService, ILogService {

    private final SysLogMapper sysLogMapper;


    /**
     * 系统日志查询
     * @param sysLog
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    @AutoPageAop
    public ResponseInfo getSysLog(SysLog sysLog, Integer pageNum, Integer pageSize) {
       String companyid = UserIdThread.get().getCompanyId();
        List<SysLog> sysList = sysLogMapper.getSysLog(sysLog,companyid);

        HashMap map = new HashMap<>();
        PageInfo list = new PageInfo(sysList);
        map.put("lotNoList", sysList);
        map.put("total", list.getTotal());
        return ResponseInfo.ok(map);
    }

    @Override
    public boolean save(SysLog sysLog) {
        return super.save(sysLog);
    }


}
